/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Estrutura;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.DriverManager;
import java.sql.Connection;
public class login {
    public Connection conectaBD(){
           //Connection con=onexaonull;
           Connection conn = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            //.newInstance();
            return DriverManager.getConnection("jdbc:mysql://localhost:3306/loja","root","root");
         } catch (Exception e) {
        }
           return null;
    }
    public String nome="";
    public boolean  resultado=false;

    public boolean  verificaResultado (String login, String senha){
        String sql="select usuario,senha from USUARIO WHERE USUARIO='" + login + "' and senha='"+ senha+ "'";

        try {
          Connection con = this.conectaBD();
          Statement st= con.createStatement();
          ResultSet rs=st.executeQuery(sql);

           if (rs.next()){
                resultado=true;
                rs.getString("nome");
            }

        } catch (Exception e) {
         e.printStackTrace();
        }
        return resultado;
    }
}


